package com.demo;


import sun.reflect.generics.tree.Tree;

import java.util.*;

public class Demo2 {

    public static void main(String[] args) {


        Map<Person, String> map = new TreeMap<Person, String>();
        Person p1 = new Person("a", 1);
        Person p2 = new Person("a", 1);
        Person p3 = new Person("c", 1);

        map.put(p1, "zzz");
        map.put(p2, "yzm");
        map.put(p3, "clw");


        System.out.println(map.size());
        /*Iterator<Map.Entry<String,String>> iterator=map.entrySet().iterator();
        while (iterator.hasNext()){
            Map.Entry<String,String> mapEntry=iterator.next();
            System.out.println(mapEntry.getKey()+" "+mapEntry.getValue());
        }


*/

        /*for (String key:map.keySet()
             ) {
            System.out.println(key+" "+map.get(key));
        }*/


        Set<String> set = new HashSet<String>();
        set.add("a");
        set.add("d");
        set.add("c");
        set.add("b");

        Iterator<String> iterator = set.iterator();
        boolean b1 = set.contains("b");
        boolean b2 = set.isEmpty();
        String s[] = set.toArray(new String[]{});
        Object object[] = set.toArray();
        int n = set.size();
        set.remove("d");


        //Lambda 表达式
       /* Comparator<Person> comparator = (Person pa,Person pb) ->
        {
            if(pa.getAge()==pb.getAge()){
               return  pa.getName().compareTo(pb.getName());
            }else{
               return pa.getAge()-pa.getAge();
            }
        };
        TreeSet<Person> set = new TreeSet<Person>(comparator);
        set.add(new Person("zzz", 20));
        set.add(new Person("zzz", 21));
        set.add(new Person("zzz", 22));
        System.out.println(set.size());*/
    }
}

class Person {
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }


}
